﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utility;

namespace Service
{
    public class Config
    {
        public int StartFloor { get; set; }

        public int EndFloor { get; set; }

        public int HorizontalOffset { get; set; }

        public int VerticalOffset { get; set; }

        public int CentralLatitude { get; set; }

        public int CentralLongitude { get; set;}

        public string CellFile { get; set; }

        public string BuildSource { get; set; }
        public string ResultFolder { get; set; }
        public int GridLength { get; set; }

        //分片大小
        public int SliceLength { get; set; }

        //577
        public string City { get; set; }

        public static Config Init()
        {
            var config = new Config();
            string configFile = System.AppDomain.CurrentDomain.BaseDirectory + "\\config.txt";
            FileUtil.ReadFileLineContent(configFile, line =>
            {
                var arr = line.Split(',');
                switch (arr[0])
                {
                    case "startfloor":
                        config.StartFloor = Convert.ToInt32(arr[1]);
                        break;
                    case "endfloor":
                        config.EndFloor = Convert.ToInt32(arr[1]);
                        break;
                    case "horizontaloffset":
                        config.HorizontalOffset = Convert.ToInt32(arr[1]);
                        break;
                    case "verticaloffset":
                        config.VerticalOffset = Convert.ToInt32(arr[1]);
                        break;
                    case "centrallongitude":
                        config.CentralLongitude = Convert.ToInt32(arr[1]);
                        break;
                    case "centrallatitude":
                        config.CentralLatitude = Convert.ToInt32(arr[1]);
                        break;
                    case "cellfile":
                        config.CellFile = arr[1];
                        break;
                    case "buildsource":
                        config.BuildSource = arr[1];
                        break;
                    case "resultfolder":
                        config.ResultFolder = arr[1];
                        break;
                    case "gridlength":
                        config.GridLength = Convert.ToInt32(arr[1]);
                        break;
                    case "slicelength":
                        config.SliceLength = Convert.ToInt32(arr[1]);
                        break;
                    case "city":
                        config.City = arr[1];
                        break;
                    default:
                        break;
                }
            });

            return config;
        }

    }
}
